import { IComponent } from "./base/IComponent";
import { error } from "@tauri-apps/plugin-log";

class _Icon extends IComponent {
    public static id: number = 0;
    private _element: HTMLDivElement = document.createElement('div');

    constructor(source: string) {
        super(`btn-${_Icon.id++}`);
        this._element.classList.add('codicon', `codicon-${source}`)
    }

    build(parentId?: string) {
        try {
            super._build(this._element, parentId);
        } catch (e) {
            error(`error ${e}`);
        }
    }
}

export function Icon(source: string): _Icon {
    return new _Icon(source);
}